/**
 * 智慧小区管理系统 - 维修服务类型定义
 * @author Wu.Liang
 * @date 2024-12-21
 */

// API响应类型
export interface ApiResponse<T = unknown> {
  code: number
  message: string
  data: T
  success: boolean
}

// 分页响应类型
export interface PageResponse<T = any> {
  records: T[]
  total: number
  current: number
  size: number
  pages: number
}

// 基础查询参数
export interface BaseQueryParams {
  current?: number
  size?: number
  keyword?: string
}

// 维修工单类型
export interface RepairOrder {
  id: number
  orderNo: string
  title: string
  description: string
  userId: number
  userName: string
  communityId: number
  communityName: string
  householdId?: number
  householdInfo?: string
  repairType: number
  repairAddress: string
  contactPhone: string
  urgencyLevel: number
  status: number
  repairmanId?: number
  repairmanName?: string
  assignTime?: string
  startTime?: string
  completionTime?: string
  cancelTime?: string
  cancelReason?: string
  completeResult?: string
  satisfactionScore?: number
  processingTime?: string | number
  overdue?: boolean
  repairImages?: string | any[]
  remark?: string
  createTime: string
  updateTime: string
}

// 维修工单进度类型
export interface RepairProgress {
  id: number
  orderId: number
  orderNo: string
  progressType: number
  progressTitle: string
  progressContent: string
  progressTime: string
  operatorId?: number
  operatorName?: string
  repairmanId?: number
  repairmanName?: string
  remark?: string
  status: number
  sortOrder: number
  createTime: string
  progressTypeName?: string
}

// 创建工单参数
export interface CreateOrderParams {
  userId: number
  communityId: number
  repairType: number
  title: string
  description: string
  repairAddress: string
  contactPhone: string
  urgencyLevel: number
  householdId?: number
  location?: string
  priority?: number
  remark?: string
}

// 分配工单参数
export interface AssignOrderParams {
  repairmanId: number
  remark?: string
}

// 完成工单参数
export interface CompleteOrderParams {
  result: string
  remark?: string
}

// 维修工单统计信息
export interface RepairOrderStatistics {
  totalOrders: number
  pendingOrders: number
  processingOrders: number
  completedOrders: number
  cancelledOrders: number
  averageProcessingTime: number
  onTimeCompletionRate: number
  statusDistribution: Record<string, number>
  typeDistribution: Record<string, number>
  urgencyDistribution: Record<string, number>
}

// 维修人员类型
export interface Repairman {
  id: number
  name: string
  phone: string
  specialty: string
  status: number
  currentOrders: number
  totalCompleted: number
  rating: number
}

// 社区信息类型
export interface Community {
  id: number
  name: string
  address: string
  propertyCompanyId: number
  propertyCompanyName: string
}

// 房户信息类型
export interface Household {
  id: number
  communityId: number
  buildingId: number
  unitId: number
  roomNumber: string
  floor: number
  area: number
  status: number
  ownerName: string
  ownerPhone: string
}

// 表单验证规则
export interface FormRules {
  [key: string]: any[]
} 